<include file="Public/head"/>
<body class="no-skin">
<include file="Public/header"/>
<div class="main-container" id="main-container">
    <script type="text/javascript">
        try {
            ace.settings.check('main-container', 'fixed')
        } catch (e) {
        }
    </script>

    <include file="Public/sidebar"/>
    <div class="main-content">
        <div class="main-content-inner">
            <!-- #section:basics/content.breadcrumbs -->
            <include file="Public/breadcrumbs"/>

            <!-- /section:basics/content.breadcrumbs -->
            <div class="page-content">
                <include file="Public/set"/>

                <!-- /section:settings.box -->
                <div class="row">
                    <div class="col-xs-12">
                        <!-- PAGE CONTENT BEGINS -->
                        <form class="form-horizontal" action="#" method="post">
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-1"> 选择平台 </label>
                                <div class="col-sm-9">
                                    <input type="text" value="{$extend.platform}" disabled="disabled">
                                </div>
                            </div>

                            <div class="space-4"></div>

                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-2"> 推广绑定域名 </label>
                                <div class="col-sm-9">
                                    <input type="text" name="domain" id="domain" placeholder="请输入绑定域名"
                                           class="col-xs-10 col-sm-5" value="{$extend.domain}">
                                    <span class="help-inline col-xs-12 col-sm-7">
                                    </span>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-2"> 小说名 </label>
                                <div class="col-sm-9">
                                    <input type="text" name="novel_name" id="novel_name" placeholder="请输入小说名"
                                           class="col-xs-10 col-sm-5" value="<?php echo empty($extend['novel_name'])?'':$extend['novel_name']?>">
                                    <span class="help-inline col-xs-12 col-sm-7">
                                    </span>
                                </div>
                            </div>

                            <div class="space-4"></div>

                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-10"> 选择章节 </label>
                                <div class="col-sm-9">
                                    <select id="chapter_id" name="chapter_id" class="rcol-xs-10 col-sm-5">
                                        <?php if(!empty($list)):?>
                                            <?php foreach($list as $v):?>
                                                <option value="<?php echo $v['id']?>"  <?php  if($pre_chapter_id==$v['id'])echo selected?>><?php echo $v['chapter'].'---'.$v['title'];?></option>
                                            <?php endforeach;?>
                                        <?php endif;?>
                                        <!--<if condition="$list neq ''">-->
                                            <!--<volist name="$list" id="v">-->
                                                <!--<option value="$v.id">{$v.chapter}-&#45;&#45;{$v.title}</option>-->
                                            <!--</volist>-->
                                        <!--</if>-->
                                    </select>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-2"> 推送的统计ID </label>
                                <div class="col-sm-9">
                                    <input type="text" name="tongji_id" id="tongji_id" placeholder="请输入统计ID"
                                           class="col-xs-10 col-sm-5" value="{$extend.tongji_id}">
                                    <span class="help-inline col-xs-12 col-sm-7">
                                    </span>
                                </div>
                            </div>

                            <div class="space-4"></div>

                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-2"> 是否屏蔽二维码 </label>
                                <div class="control-label no-padding-left col-sm-1">
                                    <label>
                                        <input type="radio" name="is_push" value="1" <?php echo $extend['is_push']==1?checked:''?>/>是
                                        <input type="radio" name="is_push" value="0" <?php echo $extend['is_push']==0?checked:''?>/>否
                                    </label>
                                </div>
                                <span class="help-inline col-xs-12 col-sm-7">
												<span class="middle"></span>
										</span>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-2"> 强行推送 </label>
                                <div class="control-label no-padding-left col-sm-1">
                                    <label>
                                        <input type="radio" name="isforce" value="1" <?php echo $extend['is_force']==1?checked:''?>/>是
                                        <input type="radio" name="isforce" value="0" <?php echo $extend['is_force']==0?checked:''?>/>否
                                    </label>
                                </div>
                                <span class="help-inline col-xs-12 col-sm-7">
												<span class="middle"></span>
										</span>
                            </div>
                            

                            <div class="space-4"></div>
                            <input type="hidden" id="extend_id" value="{$extend.id}">
                            <div class="col-md-offset-2 col-md-9">
                                <button class="btn btn-info" type="button" id="submitbtn">
                                    <i class="icon-ok bigger-110"></i>
                                    提交
                                </button>

                                &nbsp; &nbsp; &nbsp;
                                <button class="btn" type="reset">
                                    <i class="icon-undo bigger-110"></i>
                                    重置
                                </button>
                            </div>
                        </form>
                        <!-- PAGE CONTENT ENDS -->
                    </div><!-- /.col -->
                </div><!-- /.row -->
            </div><!-- /.page-content -->
        </div>
    </div><!-- /.main-content -->
    <include file="Public/footer"/>

</div><!-- /.main-container -->

<include file="Public/footerjs"/>
<!-- inline scripts related to this page -->
<script src="__PUBLIC__/qwadmin/js/date-time/bootstrap-datepicker.js"></script>
<script src="__PUBLIC__/qwadmin/js/function.js"></script>
<script type="text/javascript">
    jQuery(function ($) {
        $('#birthday').datepicker({
            format: 'yyyy-mm-dd',
            weekStart: 1,
            autoclose: true,
            todayBtn: 'linked',
            language: 'cn'
        });
    });
    $(function(){
        $('#novel_name').change(function(){
            var htmls = '';
            $.post("{:U('Getlist')}",
                    {
                        'keyword':$(this).val()
                    },function(data){
                        var datas = $.parseJSON(data);
                        if(datas.status==1){
                            var b = datas.data;
                            b.forEach(function(e){
                                htmls+='<option value="'+e.id+'">'+ e.chapter+'---'+e.title+'</option>';
                            })
                            $('#chapter_id').html(htmls);
                        }else{
                            alert('输入的小说不存在，请重新输入');
                        }
                    })
        });
        $('#submitbtn').click(function(){
            var domain = "<?php echo $_SERVER['HTTP_HOST'] ?>";
            $.post("{:U('extend_edit')}",
                    {
                        'id':$('#extend_id').val(),
                        'novel_name':$('#novel_name').val(),
                        'chapter_id':$('#chapter_id option:checked').val(),
                        'is_force':$('input[name="isforce"]:checked').val(),
                        'is_push':$('input[name="is_push"]:checked').val(),
                        'tongji_id':$('#tongji_id').val(),
                        'domain':$('#domain').val()
                    },function(data){
                        if (data.status == 1) {
                            alert(data.message);
                        }else {
                            alert(data.message);
                        }
                        window.location.href = "/ProxyDomain/extension";
                    },'json');
        })
    });
</script>
</body>
</html>
